import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)
//添加以下代码
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    meta: {
      index: 0,
      NavShow: true
    }
  },

  {
    path: '/vip',
    name: 'vip',
    component: () => import('../views/VipView.vue'),
    meta: {
      index: 1,
      NavShow: true
    }
  },
  // 订阅页面
  {
    path: '/subscribe',
    name: 'sub',
    component: () => import('../views/SubView.vue'),
    meta: {
      index: 2,
      NavShow: true
    }
  },
  {
    path: '/my',
    name: 'my',
    component: () => import('../views/MyView.vue'),
    meta: {
      index: 3,
      NavShow: true
    }
  },
  // 搜索页面
  {
    path: '/search',
    name: 'search',
    component: () => import('../views/SearchView.vue'),
    meta: {
      index: 4,
      NavShow: false
    },
    children: [
      // 搜索点击每个item页面
      {
        path: '/search/ItemView',
        name: 'ItemView',
        component: () => import('../views/ItemView.vue'),
        meta: {
          index: 5,
          NavShow: false
        }
      },
    ]
  },
  // 分类图标点击进入详情分类页
  {
    path: "/ClassView",
    name: 'Class',
    component: () => import("../views/ClassView.vue"),
    meta: {
      index: 6,
      NavShow: false
    }
  },
  // 观念日历更能多按钮
  {
    path: "/IdeaDateView",
    name: 'IdeaDateView',
    component: () => import("../views/IdeaDateView.vue"),
    meta: {
      index: 7,
      NavShow: false
    }
  },
  // 每日金句 更多按钮跳转
  {
    path: "/DailySentenceView",
    name: 'DailySentence',
    component: () => import("../views/DailySentenceView.vue"),
    meta: {
      index: 7,
      NavShow: false
    }
  },
  // 有声节目详情页
  {
    path: "/BookDetails",
    name: "BookDetails",
    component: () => import("../views/BookDetailsView.vue"),
    meta: {
      index: 6,
      NavShow: false
    },
  },
  // 单集节目页SingleSetView
  {
    path: "/SingleSetView",
    name: "SingleSet",
    component: () => import("../views/SingleSetView.vue"),
    meta: {
      index: 7,
      NavShow: false
    },
  },
  // 作者页
  {
    path: "/AuthorPageView",
    name: "AuthorPage",
    component: () => import("../views/AuthorPageView.vue"),
    meta: {
      index: 6,
      NavShow: false
    },
  },

  // 登录注册页
  {
    path: "/LoginAndEgistration",
    name: "LoginAndEgistration",
    component: () => import("../views/LoginAndEgistration.vue"),
    meta: {
      index: 8,
      NavShow: false
    },
  },
  // 404页面
  {
    path: "*",
    component: () => import("../views/ErrorView.vue")
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
